import 'package:mobile_app.core/core/domain/entities/learning_content/lexical_item/lexical_item.dart';
import 'package:mobile_app.home.core/core/domain/entities/card_actions/removal_from_learning_queue_card_action.dart';
import 'package:mobile_app.home.core/core/domain/helpers/is_removal_from_learning_queue_card_action_reasonable/helper.dart';

abstract class CreateRemovalFromLearningQueueCardActionIfReasonable {
  RemovalFromLearningQueueCardAction? call({
    required LexicalItem lexicalItem,
  });
}

class CreateRemovalFromLearningQueueCardActionIfReasonableImpl
    implements CreateRemovalFromLearningQueueCardActionIfReasonable {
  const CreateRemovalFromLearningQueueCardActionIfReasonableImpl({
    required IsRemovalFromLearningQueueCardActionReasonable
        isRemovalFromLearningQueueCardActionReasonable,
  }) : _isRemovalFromLearningQueueCardActionReasonable =
            isRemovalFromLearningQueueCardActionReasonable;

  final IsRemovalFromLearningQueueCardActionReasonable
      _isRemovalFromLearningQueueCardActionReasonable;

  @override
  RemovalFromLearningQueueCardAction? call({
    required LexicalItem lexicalItem,
  }) {
    final cardActionReasonable = _isRemovalFromLearningQueueCardActionReasonable(
      lexicalItem: lexicalItem,
    );

    if (!cardActionReasonable) {
      return null;
    }

    return const RemovalFromLearningQueueCardAction();
  }
}
